package com.its.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.its.mapper.GoodsOrderMapper;
import com.its.pojo.GoodsOrder;
import com.its.service.GoodsOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author lenovo
* @description 针对表【gym_goods_order】的数据库操作Service实现
* @createDate 2025-05-29 18:05:47
*/
@Service
public class GoodsOrderServiceImpl extends ServiceImpl<GoodsOrderMapper, GoodsOrder> implements GoodsOrderService {
    //注入Mapper层属性
    @Autowired
    private GoodsOrderMapper goodsOrderMapper;

    //生成订单
    @Override
    public int creatGoodsOrder(GoodsOrder goodsOrder) {
        return goodsOrderMapper.insert(goodsOrder);
    }

    //根据用户名查询订单
    @Override
    public List<GoodsOrder> selectGoodsOrderByMemberAccount(Integer memberAccount) {
        QueryWrapper<GoodsOrder> goodsOrderQueryWrapper = new QueryWrapper<>();
        goodsOrderQueryWrapper.eq("member_account",memberAccount);
        return goodsOrderMapper.selectList(goodsOrderQueryWrapper);
    }

    //查询所有订单
    @Override
    public Page<GoodsOrder> selectAllGoodsOrder(Integer page, Integer size) {
        return goodsOrderMapper.selectPage(new Page<>(page,size),null);
    }
}




